<?php

namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class EquipRecordCar extends Model{
    protected $table = "equip_record_car";
    protected $dateFormat = 'Y-m-d H:i:s';
    protected $casts = [
        'created_at' => 'datetime:Y-m-d H:i:s',
        'updated_at' => 'datetime:Y-m-d H:i:s',
        'delete_at' => 'datetime:Y-m-d H:i:s',
    ];
    protected $guarded = array('*');
    protected $fillable = ['equip_code',
        'project_id',
        'project_name',
        'equip_id',
        'equip_name',
        'site_id',
        'site_name',
        'created_user_id',
        'created_user_name',
        'user_ids',
        'users',
        'check_status',
        'check_xxy_id',
        'check_xxy_name',
        'check_jl_id',
        'check_jl_name',
        'content',
        'longitude',
        'latitude',
        'hour',
        'onoff',
        'status',
        'nh_qy_lq',
        'nh_qy_xh',
        'nh_cy_lq',
        'nh_cy_xh',
        'nh_hdl',
        'yaoji_pac',
        'yaoji_pac_qf',
        'yaoji_pac_ts',
        'yaoji_pam',
        'yaoji_pam_qf',
        'yaoji_pam_ts',
        'shui_dalao',
        'shui_chuli',
        'llj_1_start',
        'llj_1_close',
        'created_at',
        'updated_at',
        'delete_at',
        'zaoni_sc',
        'zaoni_wy',
        'day_time'
       ];

    public function addData($data)
    {
        DB::beginTransaction();
        try {

            $record_car =  EquipRecordCar::create($data);


             DB::commit();
        }catch (\Exception $e){
                // 回滚事务
                DB::rollback();
                // 处理异常
                echo $e->getMessage();
        }


    }
}
